package com.xdap.water.controller;

import com.definesys.mpaas.common.http.Response;
import com.xdap.water.service.WaterService;
import com.xdap.water.vo.WaterCardInfoVo;
import com.xdap.water.vo.WaterChartVo;
import com.xdap.water.vo.WaterSearchParamVo;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/water")
@Slf4j
public class WaterController {
    @Autowired
    private WaterService waterService;

    @GetMapping("/queryAllProjectType")
    public Response queryAllProjectType() {
        return Response.ok().table(waterService.queryAllProjectType());
    }

    @PostMapping("/queryCardData")
    public Response queryCardData(@RequestBody WaterSearchParamVo vo) {
        log.info(vo.toString());
        return Response.ok().data(waterService.queryProjectByParams(vo));
    }

    @PostMapping("/queryTrapeziumInfo")
    public Response queryTrapeziumInfo(@RequestBody WaterSearchParamVo vo) {
        log.info(vo.toString());
        return Response.ok().table(waterService.queryTrapeziumInfo(vo));
    }

    @GetMapping("/queryResponsibleUnit")
    public Response queryResponsibleUnit() {
        return Response.ok().table(waterService.queryResponsibleUnit());
    }

    @GetMapping("/queryMinYear")
    public Response queryMinYear() {
        return Response.ok().data(waterService.queryMinYear());
    }


    @GetMapping("/v2/queryAllProjectType")
    public Response queryAllProjectTypeV2() {
        return Response.ok().table(waterService.queryProjectType());
    }

    @GetMapping("/v2/queryAllProjectUnit")
    public Response queryAllUnit() {
        return Response.ok().table(waterService.queryAllUnit());
    }

    @GetMapping("/v2/queryCurrentYearProjectYearTask")
    public Response queryCurrentYearProjectYearTask() {
        return Response.ok().table(waterService.queryCurrentYearProjectYearTask());
    }

    @GetMapping("/v2/queryCompleteStatusByDate")
    public Response queryCompleteStatusByDate(@RequestParam("date") String date) {
        return Response.ok().data(waterService.queryCompleteStatusByDate(date));
    }

    @GetMapping("/v2/queryMaxDate")
    public Response queryMaxDate() {
        return Response.ok().data(waterService.queryMaxDate());
    }

    @GetMapping("/v2/queryUnitChartData")
    public Response queryUnitChartData(
            @RequestParam("date") String date,
            @RequestParam("unit") String unit
    ) {
        return Response.ok().table(waterService.queryUnitChartData(unit, date));
    }

    @GetMapping("/v2/queryPlanInvestSchedule")
    public Response queryPlanInvestSchedule(
            @RequestParam("year") String year,
            @RequestParam(value = "unit", required = false) String unit
    ) {
        return Response.ok().table(waterService.queryPlanInvestSchedule(unit, year));
    }

    @GetMapping("/v2/queryActualInvestSchedule")
    public Response queryActualInvestSchedule(
            @RequestParam("year") String year,
            @RequestParam(value = "unit", required = false) String unit
    ) {
        return Response.ok().table(waterService.queryActualInvestSchedule(unit, year));
    }

    @GetMapping("/v2/queryPlanNtSchedule")
    public Response queryPlanNtSchedule(
            @RequestParam("year") String year,
            @RequestParam(value = "unit", required = false) String unit
    ) {
        return Response.ok().table(waterService.queryPlanNtSchedule(unit, year));
    }

    @GetMapping("/v2/queryActualNtSchedule")
    public Response queryActualNtSchedule(
            @RequestParam("year") String year,
            @RequestParam(value = "unit", required = false) String unit
    ) {
        return Response.ok().table(waterService.queryActualNtSchedule(unit, year));
    }

    @GetMapping("/v2/queryCurrentYearNtTask")
    public Response queryCurrentYearNtTask(
            @RequestParam("year") String year,
            @RequestParam(value = "unit", required = false) String unit
    ) {
        return Response.ok().data(waterService.queryCurrentYearNtTask(unit, year));
    }
}
